feat(helpers): add non-text Part, Message, and Artifact helpers#1004
Merged
guglielmo-san merged 5 commits intoa2aproject:mainfrom Apr 23, 2026
Merged
feat(helpers): add non-text Part, Message, and Artifact helpers#1004guglielmo-san merged 5 commits intoa2aproject:mainfrom
guglielmo-san merged 5 commits intoa2aproject:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces new helper functions (new_data_part, new_raw_part, and new_url_part) to proto_helpers.py for creating various Part message types, along with corresponding unit tests. A suggestion was made to broaden the type hint for new_data_part from dict[str, Any] to Any, as google.protobuf.Value can represent any JSON-serializable type, including lists and scalars.
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/helpers/proto_helpers.py | 94.12% | 95.45% | 🟢 +1.34% |
| Total | 93.02% | 93.04% | 🟢 +0.02% |
Generated by coverage-comment.yml
Part.data is google.protobuf.Value in the v1.0 spec, which requires a non-obvious ParseDict dance to construct from a plain dict. Add new_data_part() to hide that complexity. Also add new_raw_part() and new_url_part() to cover the remaining non-text Part variants that had no helpers, keeping the API consistent with new_text_message() et al.
d44e706 to
e2a1f26
Compare
1466d74 to
475e104
Compare
Member
|
LGTM, thank you for your contribution! |
guglielmo-san
approved these changes
Apr 23, 2026
ishymko
pushed a commit
that referenced
this pull request
Apr 24, 2026
🤖 I have created a release *beep* *boop* --- ## [1.0.2](v1.0.1...v1.0.2) (2026-04-24) ### Features * **helpers:** add non-text Part, Message, and Artifact helpers ([#1004](#1004)) ([cfdbe4c](cfdbe4c)) ### Bug Fixes * **proto:** use field.label instead of is_repeated for protobuf compatibility ([#1010](#1010)) ([7d197db](7d197db)) * **server:** deliver push notifications across all owners ([#1016](#1016)) ([c24ae05](c24ae05)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CONTRIBUTINGGuide.bash scripts/format.shfrom the repository root to format)Summary
proto_helpers.pyprovidednew_text_messageandnew_text_artifactfor the text Part variant, but nothing for the three remaining Part types (data,raw,url). This PR completes the set.The
datacase is especially awkward without a helper.Part.dataisgoogle.protobuf.Valuein the v1.0 spec, which requires a non-obviousParseDictdance to construct from a plain Python value:New helpers
Part primitives (building blocks, mirror the existing implicit
Part(text=...)pattern):new_data_part(data)data(google.protobuf.Value)new_raw_part(raw, media_type, filename)raw(bytes)new_url_part(url, media_type, filename)url(str)Message helpers (mirror
new_text_message):new_data_message(data, role, context_id, task_id)new_data_partnew_raw_message(raw, media_type, filename, role, context_id, task_id)new_raw_partnew_url_message(url, media_type, filename, role, context_id, task_id)new_url_partArtifact helpers (mirror
new_text_artifact):new_data_artifact(name, data, description, artifact_id)new_data_partnew_raw_artifact(name, raw, media_type, filename, description, artifact_id)new_raw_partnew_url_artifact(name, url, media_type, filename, description, artifact_id)new_url_partChanges
src/a2a/helpers/proto_helpers.py— 9 new helper functionstests/helpers/test_proto_helpers.py— tests for all new helpers (35 total, all passing)Reviewer feedback addressed
new_data_parttype hint broadened fromdict[str, Any]toAny, sincegoogle.protobuf.Valueaccepts any JSON-serializable value, not just dicts. Added a list-value test to cover this.BEGIN_COMMIT_OVERRIDE
feat(helpers): add non-text Part, Message, and Artifact helpers (#1004)
Release-As: 1.0.2
END_COMMIT_OVERRIDE